package com.pms.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.pms.entity.Folder;
import com.pms.util.DBHelp;
import com.pms.util.RowMapper;




public class FdDao {

	
	private DBHelp<Folder> db=new DBHelp<Folder>();
	public void save(Folder fd) {
	
		String sql="INSERT INTO t_folder (`name`,t_project_proid,t_user_useid) VALUE(?,?,?)";
		db.executeSQL(sql, fd.getName(),fd.getProid(),fd.getUsreid());
		
	}
	public List<Folder> finByProid(String proid) {
		String sql="SELECT `t_folder`.`id`,`t_folder`.`name`,`t_folder`.`createtime`,`t_user`.`username` FROM `t_folder` LEFT JOIN `t_user` ON `t_folder`.`t_user_useid`=`t_user`.`useid` WHERE `t_folder`.`t_project_proid`=?";
		return db.executeQueryToList(sql, new RowMapper<Folder>(){

			@Override
			public Folder mapRow(ResultSet rs) throws SQLException {
				
				Folder fd=new Folder();
				fd.setFolderid(rs.getString("id"));
				fd.setName(rs.getString("name"));
				fd.setCreatetime(rs.getString("createtime"));
				fd.setUsername(rs.getString("username"));
				
				return fd;
			}
			
	
		}, proid);
		
	}

	


}
